package com.example.datn.adapter;

import java.util.ArrayList;

import com.example.datn.R;
import com.example.datn.objects.SingerOject;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class SingerItemAdapter extends ArrayAdapter<SingerOject>{

	ImageView singerAvatar;
	TextView singerName;
	Activity context = null;
	ArrayList<SingerOject> myArray = null;
	int layoutId;
	
	public SingerItemAdapter(Activity _context, int _resource,
			ArrayList<SingerOject> _objects) {
		super(_context, _resource, _objects);
		this.context = _context;
		this.myArray = _objects;
		this.layoutId = _resource;
		
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = context.getLayoutInflater();
		convertView = inflater.inflate(layoutId, null);
		
		singerAvatar = (ImageView)convertView.findViewById(R.id.img_singerAvatar_listSinger);
		singerName = (TextView)convertView.findViewById(R.id.tv_singerName_listSinger);
		
		SingerOject singer = myArray.get(position);
		
		singerAvatar.setImageResource(singer.singerAvatarId);
		singerName.setText(singer.singerName);
		
		return convertView;
	}
	
	                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
	
}
